"""meiduo_mall URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""

from django.urls import path
from . import views

urlpatterns = [
    # SKU管理
    path('skus/', views.SKUView.as_view({'get': 'list', 'post': 'create'})),
    path('skus/categories/', views.SKUCategoriesView.as_view()),
    path('goods/<int:pk>/specs/', views.SPUSpecView.as_view()),
    path('skus/<int:pk>/',
         views.SKUView.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy', 'patch': 'partial_update'})),

    # SPU管理
    path('goods/', views.SPUView.as_view({'get': 'list', 'post': 'create'})),
    path('goods/brands/simple/', views.SPUBrandView.as_view({'get': 'list', 'post': 'create'})),
    path('goods/channel/categories/', views.GoodsChannelView.as_view({'get': 'list', 'post': 'create'})),
    path('goods/channel/categories/<int:pk>/', views.ChannelCategoryView.as_view({'get': 'list', 'post': 'create'})),
    path('goods/<int:pk>/',
         views.SPUView.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy', 'patch': 'partial_update'})),

    # 规格表管理
    path('goods/specs/', views.SpecificationView.as_view({'get': 'list', 'post': 'create'})),
    path('goods/simple/', views.SPUSimpleView.as_view()),
    path('goods/specs/<int:pk>/', views.SpecificationView.as_view({
        'get': 'retrieve', 'put': 'update', 'delete': 'destroy', 'patch': 'partial_update'
    })),

    # 规格选项管理
    path('specs/options/', views.SpecifiOptionView.as_view({'get': 'list', 'post': 'create'})),
    path('goods/specs/simple/', views.SPUOptionView.as_view()),
    path('specs/options/<int:pk>/', views.SpecifiOptionView.as_view({
        'get': 'retrieve', 'put': 'update', 'delete': 'destroy', 'patch': 'partial_update'
    })),

    # 图片管理
    path('skus/images/', views.ImageView.as_view({'get': 'list', 'post': 'create'})),
    path('skus/simple/', views.ImageSimpleView.as_view()),
    path('skus/images/<int:pk>/', views.ImageView.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy', 'patch': 'partial_update'})),
]
